<?php
/**
 * User: b179a9
 * Date: 08.09.11
 * Time: 17:28
 */

class App_Form_User_Delivery extends Zend_Form
{

    function init($options = null)
    {

        parent::init($options);

        $subject = new Zend_Form_Element_Text('subject');
        $subject->setRequired()
                ->setLabel('Subject:');
        $subject->setAttrib('class', 'text-input medium-input');
        $subject->setAttrib('placeholder', 'Subject');
        $subject->setDecorators(array('ViewHelper'));
        $subject->addErrorMessage('Please, input subject.');
        $this->addElement($subject);

        $text = new Zend_Form_Element_Textarea('text');
        $text->setRequired()
                ->setLabel('Text: ');
        $text->setAttrib('class', 'text-input');
        $text->setAttrib('placeholder', 'Text');
        $text->setDecorators(array('ViewHelper'));
        $text->addErrorMessage('Please, input text of the message.');
        $this->addElement($text);

        $preview = new Zend_Form_Element_Checkbox('preview');
        $preview->setLabel('Preview');
        $preview->setDecorators(array('ViewHelper'));
        $this->addElement($preview);

        $map = new Zend_Form_Element_Select('map');
        $map->setLabel('Map:');
        $map->setDecorators(array('ViewHelper'));

        $map->addMultiOption('', 'All');
        $mapsManager = new \Managers\Map();
        $maps = $mapsManager->getList();
        foreach($maps as $value) {
            $map->addMultiOption($value['id'], $value   ['title']);
        }
        $this->addElement($map);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Send')
            ->setAttrib('class', 'button');
        $this->addElement($submit);

        $this->setDecorators(array(array('ViewScript', array('viewScript' => '/forms/user/delivery.phtml'))));

    }

}
